def statistic(num_list):
    num_sum = 0
    max_num = -float('inf')
    min_num = float('inf')

    i = 0
    while i < len(num_list):
        num_sum += num_list[i]  # 累加
        if num_list[i] > max_num:  # 判断最大值for
            max_num = num_list[i]
        if num_list[i] < min_num:  # 判断最小值j
            min_num = num_list[i]
        i += 1

    avg_num = num_sum / len(num_list)  # 求平均

    return num_sum, avg_num, max_num, min_num


if __name__ == '__main__':
    num_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    stat = statistic(num_list)
    print(stat)
